<template>
  <div class="common-card common-bkg-border">
    <div class="card-header">
      <div class="left">
        <div class="card-icon">
          <img :src="imgUrl" alt="">
        </div>
        <div class="card-titile">
          <span>{{props.title}}</span>
        </div>
      </div>
      <div class="right">
        <div class="close-icon" v-if="props.canClose" @click="Click">
          <img src="@/assets/img/close.svg" alt="">
        </div>
      </div>
    </div>
    <div class="card-content">
      <slot></slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defineProps, computed ,defineEmits} from 'vue'
const emit = defineEmits(['close'])
const Click=()=>{
  emit('close')
}
const props = defineProps<{
  title: string
  iconName: string
  canClose?: boolean
}>()
const imgUrl = computed(() => require(`@/assets/img/${props.iconName}.svg`))
</script>


<style scoped lang="scss">
.common-card {
  width:100%;
  height:100%;
  box-sizing: border-box;
  padding:20px;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .left {
      display: flex;
      align-items: center;
      .card-icon {
        width: 20px;
        height: auto;
        img {
          display: block;
          width: 100%;
          height: auto;
        }
      }
    }
    .right {
      display: flex;
      align-items: center;
    }
    .card-titile {
      color: #fff;
      margin-left: 10px;
    }
    .close-icon {
      cursor: pointer;
      width: 12px;
      height: auto;
      img {
        display: block;
        width: 100%;
        height: auto;
      }
    }
  }
  .card-content {
    flex: 1;
    height: 0;
  }
}
</style>
